#ifndef MOCHA_DETAIL_PLUGIN_H_INCLUDED
#define MOCHA_DETAIL_PLUGIN_H_INCLUDED

/**
 * @file
 */

#include <stdint.h>
#include "mocha/api.h"
#include "mocha/memory.h"

#define MOCHA_PLUGIN_VERSION_MAJOR 0
#define MOCHA_PLUGIN_VERSION_MINOR 0
#define MOCHA_PLUGIN_VERSION_REVISION 0

#ifdef __cplusplus
extern "C" {
#endif

typedef int8_t mocha_plugin_char_t;
typedef struct mocha_plugin_factory_params mocha_plugin_factory_params;
/**
 *
 */
typedef enum mocha_plugin_language {
	mocha_plugin_language_c,
	mocha_plugin_language_cpp
} mocha_plugin_language;
/**
 *
 */
typedef struct MOCHA_PACKED mocha_plugin_object_params {
	const mocha_plugin_char_t *type;
	const mocha_plugin_factory_params *fp;
} mocha_plugin_object_params;
/**
 *
 */
typedef struct MOCHA_PACKED mocha_plugin_api_version {
	uint16_t major;
	uint16_t minor;
	uint16_t revision;
} mocha_plugin_api_version;
///
const static mocha_plugin_api_version mocha_plugin_compiled_api_version = { MOCHA_PLUGIN_VERSION_MAJOR, MOCHA_PLUGIN_VERSION_MINOR, MOCHA_PLUGIN_VERSION_REVISION };
///
typedef void *(*mocha_plugin_create_func_t)(mocha_plugin_object_params*);
///
typedef void *(*mocha_plugin_clone_func_t)(const void*);
///
typedef int32_t (*mocha_plugin_destroy_func_t)(void*);
/**
 *
 */
typedef struct MOCHA_PACKED mocha_plugin_register_params {
	mocha_plugin_api_version version;
	mocha_plugin_create_func_t create;
	mocha_plugin_clone_func_t clone;
	mocha_plugin_destroy_func_t destroy;
	mocha_plugin_language language;
} mocha_plugin_register_params;
///
typedef int32_t (*mocha_plugin_service_func_t)(void *sp);
///
typedef int32_t (*mocha_plugin_register_object_func_t)(mocha_plugin_factory_params *fp, const mocha_plugin_char_t *type, const mocha_plugin_register_params *rp);
///
typedef int32_t (*mocha_plugin_register_service_func_t)(mocha_plugin_factory_params *fp, const mocha_plugin_char_t *name, mocha_plugin_service_func_t func);
///
typedef int32_t (*mocha_plugin_invoke_service_func_t)(mocha_plugin_factory_params *fp, const mocha_plugin_char_t *name, void *sp);
/**
 *
 */
struct MOCHA_PACKED mocha_plugin_factory_params {
	mocha_plugin_api_version version;
	mocha_plugin_register_object_func_t register_object;
	mocha_plugin_register_service_func_t register_service;
	mocha_plugin_invoke_service_func_t invoke_service;
};
///
typedef int32_t (*mocha_plugin_deinit_func_t)();
///
typedef mocha_plugin_deinit_func_t (mocha_plugin_init_func_t)(const mocha_plugin_factory_params *fp, int32_t *rc);
///
//MOCHA_EXTERN MOCHA_PLUGIN_API mocha_plugin_deinit_func_t mocha_plugin_init_plugin(const mocha_plugin_factory_params *fp, int32_t *rc);

#ifdef __cplusplus
} // extern "C"
#endif

#endif

